﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/*
 * 生成的pot1和cat跳的格子行为是一样的
 * Item类为方便管理这两个事件
 */
public class Item : MonoBehaviour
{
    public GameController game;

    //行列值
    public int rowIndex;
    public int columnIndex;

    //偏移值
    public float xOff = -2.25f;
    public float yOff = -3f;

    public void UpdatePosition()
    {
        Vector3 v = new Vector3(0, 0, 0);
        v.x = 0.5f * columnIndex + xOff;

        //偶数行x轴往右移动0.25
        if (rowIndex%2 == 0)
        {
            v.x = 0.5f * columnIndex + xOff + 0.25f;
        }

        v.y = 0.5f * rowIndex + yOff;

        transform.position = v;
    }

    public void Goto(int rowIndex, int columnIndex)
    {
        this.rowIndex = rowIndex;
        this.columnIndex = columnIndex;
        UpdatePosition();
    }

    void OnMouseDown()
    {
        game.Select(this);
    }
}
